package com.leyou.controller;

import com.leyou.service.UserLoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
 * @author jshstart
 * @creat 2020-12-23 15:41
 */
@RestController
@RequestMapping("/user")
public class UserLoginController {
    @Autowired
    private UserLoginService userLoginService;
    @PostMapping("/login")
    public ResponseEntity<Void> userLogin(@RequestParam("username") String username,
                                    @RequestParam("password") String password,
                                    HttpServletResponse response
                          ){
        userLoginService.userLogin(username,password,response);
        return ResponseEntity.ok().build();
    }
    @PostMapping("/logout")
    public ResponseEntity<Void> userLogout(HttpServletRequest request,HttpServletResponse response){
        userLoginService.userLogout(request,response);
        return ResponseEntity.ok().build();
    }
}
